#include "osgi-predefined.h"

namespace MicroKernelRuntime
{
#define IID_MsgBroker "IID_MsgBroker"
#define SID_MsgBroker "SID_MsgBroker"

#define SERIALIZE_MODE_DICTIONARY   1
#define SERIALIZE_MODE_PROTOBUF     2
#define SERIALIZE_MODE_FLATBUFFRS   3

#define INVOKE_RESCODE_OK           1
#define INVOKE_RESCODE_TIMEOUT      2
#define INVOKE_RESCODE_FAILED       3

//消息处理函数
OSGI_INTERFACE IPublishMsgHandler
{
    virtual void OSGI_API OnMsgCall(
                char * msgType,
                int serializeMode,
                IMemBufReader * msgcontent) = 0;
};

OSGI_INTERFACE IQueueMsgHandler
{
    virtual void OSGI_API OnMsgCall(
                char * msgType,
                int serializeMode,
                IMemBufReader * msgcontent) = 0;
};



OSGI_INTERFACE IMsgBroker : public IService
{
    virtual int OSGI_API PublishTopicMsg(
                char * msgType,
                int serializeMode,
                IMemBufReader * msgContent,
                IDictionary * msgContext,
                int prioLevel = LEVEL_EXCHANGE_GENERAL) = 0;

    virtual int OSGI_API PublishQueueMsg(
                char * msgType,
                int serializeMode,
                IMemBufReader * msgContent,
                IDictionary * msgContext,
                int prioLevel = LEVEL_EXCHANGE_GENERAL) = 0;

    virtual int OSGI_API RegisterPublishMsgHandle(
                const char * msgType,
                IPublishMsgHandler * pHandler,
                const char * serviceName) = 0;

    virtual int OSGI_API UnRegisterPublishMsgHandler(
                const char * msgType,
                IPublishMsgHandler * pHandler,
                const char * serviceName = NULL) = 0;

    virtual int OSGI_API RegisterQueueMsgHandler(
                const char * msgType,
                IQueueMsgHandler * pHandler,
                const char * serviceName) = 0;

    virtual int OSGI_API UnRegisterQueueMsgHandler(
                const char * msgType,
                IQueueMsgHandler * pHandler,
                const char * serviceName = NULL) = 0;

};


}
